From f8d654a51fcac5285b127465b01f6335ab3223aa Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Sun, 1 Jul 2018 08:45:33 -0600 Subject: [PATCH] get rid of more unneeded const_cast. --- compegps.cc | 8 ++++---- csv_util.cc | 9 ++++----- vecs.cc | 6 +++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/compegps.cc b/compegps.cc index 74be6fa81..362df191a 100644 --- a/compegps.cc +++ b/compegps.cc @@ -78,8 +78,8 @@ static int snlen; static int radius; static int input_datum; -static route_head* curr_track; -static route_head* curr_route; +static const route_head* curr_track; +static const route_head* curr_route; /* placeholders for options */ @@ -514,7 +514,7 @@ write_waypt_cb(const Waypoint* wpt) static void write_route_hdr_cb(const route_head* rte) { - curr_route = const_cast(rte); + curr_route = rte; curr_index++; if (curr_index != target_index) { return; @@ -540,7 +540,7 @@ static void write_track_hdr_cb(const route_head* trk) { track_info_flag = 0; - curr_track = const_cast(trk); + curr_track = trk; curr_index++; if (curr_index != target_index) { diff --git a/csv_util.cc b/csv_util.cc index 439f6f191..6bfcc9349 100644 --- a/csv_util.cc +++ b/csv_util.cc @@ -480,7 +480,7 @@ human_to_dec(const char* instr, double* outlat, double* outlon, int which) const char* cur; double* numres = unk; int numind = 0; - char* buff; + char* buff = nullptr; if (strchr(instr, ',') != nullptr) { char* c; @@ -488,12 +488,11 @@ human_to_dec(const char* instr, double* outlat, double* outlon, int which) while ((c = strchr(buff, ','))) { *c = '.'; } + cur = buff; } else { - buff = const_cast(instr); + cur = instr; } - cur = buff; - while (cur && *cur) { switch (*cur) { case 'n': @@ -626,7 +625,7 @@ human_to_dec(const char* instr, double* outlat, double* outlon, int which) *outlon *= lonsign; } } - if (buff != instr) { + if (buff) { xfree(buff); } } diff --git a/vecs.cc b/vecs.cc index 5417f1af3..a665d7cb3 100644 --- a/vecs.cc +++ b/vecs.cc @@ -1179,7 +1179,7 @@ assign_option(const char* module, arglist_t* ap, const char* val) if (case_ignore_strcmp(val, ap->argstring) == 0) { c = ""; } else { - c = const_cast(val); + c = val; } switch (ap->argtype & ARGTYPE_TYPEMASK) { @@ -1290,7 +1290,7 @@ find_vec(const char* vecname, const char** opts) if (opt) { found = 1; assign_option(svecname, ap, opt); - xfree(const_cast(opt)); + xfree(opt); continue; } } @@ -1347,7 +1347,7 @@ find_vec(const char* vecname, const char** opts) if (opt) { found = 1; assign_option(svecname, ap, opt); - xfree(const_cast(opt)); + xfree(opt); continue; } } -- 2.30.2